﻿namespace Growatt.ShinebusServiceUploadPack.Service.OSS
{
    public class FileCheck
    {
        public static async Task<List<string>> GetBinAndHexFilesAsync(string folderPath)
        {
            List<string> binHexFiles = new List<string>();

            try
            {
                // 检查文件夹是否存在
                if (!Directory.Exists(folderPath))
                {
                    Console.WriteLine("指定的文件夹不存在: " + folderPath);
                    return binHexFiles;
                }

                // 获取文件夹中的所有.bin和.hex文件
                string[] binFiles = Directory.GetFiles(folderPath, "*.bin");
                string[] hexFiles = Directory.GetFiles(folderPath, "*.hex");
                string[] txtFiles = Directory.GetFiles(folderPath, "*.txt");

                // 将文件路径添加到列表中
                binHexFiles.AddRange(binFiles);
                binHexFiles.AddRange(hexFiles);
                binHexFiles.AddRange(txtFiles);

                //Console.WriteLine("获取文件成功，共找到 " + binHexFiles.Count + " 个文件。");
            }
            catch (Exception ex)
            {
                Console.WriteLine("获取文件时发生错误: " + ex.Message);
            }

            return binHexFiles;
        }

    }
}
